import momoent from 'moment';
export default {
    
    fcTime(row, column, cellValue, index){
        let date = new Date(cellValue);
        let Y = date.getFullYear();
        let M = date.getMonth() + 1;
        let D = date.getDate();
        let h = date.getHours();
        let m = date.getMinutes();
        let s = date.getSeconds();
        M = M<10?'0'+M:M;
        D = D<10?'0'+D:D;
        h = h<10?'0'+h:h;
        m = m<10?'0'+m:m;
        s = s<10?'0'+s:s; 
        return `${Y}/${M}/${D} ${h}:${m}:${s}`
    },
    fcDate(row, column, cellValue, index){
        let date = new Date(cellValue);
        let Y = date.getFullYear();
        let M = date.getMonth() + 1;
        let D = date.getDate();
        M = M<10?'0'+M:M;
        D = D<10?'0'+D:D;
        return `${Y}-${M}-${D}`
    },
    /**
     * 将中国标准时间转化
     * @param {中国标准时间} timestamp 
     * @returns 
     */
    timestampToTime(timestamp){
        // var chinaStandard=Mon Jul 19 2021 11:11:55 GMT+0800 (中国标准时间);
            let date = new Date(timestamp);
            let Y = date.getFullYear();
            let M = date.getMonth() + 1;
            let D = date.getDate();
            let h = date.getHours();
            let m = date.getMinutes();
            let s = date.getSeconds();
            M = M<10?'0'+M:M;
            D = D<10?'0'+D:D;
            h = h<10?'0'+h:h;
            m = m<10?'0'+m:m;
            s = s<10?'0'+s:s; 
            return `${Y}/${M}/${D} ${h}:${m}:${s}`
      },

    // 时间戳转化为年-月-日的形式
      fTimestampToYMD(cellValue){
        let date = momoent(cellValue).format("YYYY-MM-DD");
        return date;
      },

    fonline3({online}){
        // console.log(online)
        return online?'使用中':'未使用';
    },

    fonline2({online}){
        return online?'在线':'离线';
    },
 //在线状态转换成中文
 fonline(row, type) {
    if (type === 'sensor') {
        return row.online ? '在线' : '离线';
    } else {
        return row.online ? '在使用' : '未使用';
    }
}

}